var userViewParams = {
    action: {
        findMyUser: "sysUser/findMyUserVo",
        findPageMyLoginLog: "loginLog/selectPageMyLoginLog"
    }
}
$(function () {
    findMyUserVo();
    findPageMyLoginLog();
});
/**
 * @title:<h3> 显示用户信息 <h3>
 * @author: loy
 * @date: 2018/10/28 19:46
 * @params
 * @return
 **/
function findMyUserVo() {
    requestUtilParams.xhrGet(userViewParams.action.findMyUser).done(function (res) {
        var user = res.data.user;
        //设置头像
        if (res.data.fileLog != null) {
            $("#portrait_img_view").attr("src", requestUtilParams.host+"files/upload/"+res.data.fileLog.save_path);
        }
        var sex = ["保密", "男", "女"];
        $("#role_names_view").text(baseUtilParams.strNullFilter(res.data.role_names));
        $("#name_user_view").text(baseUtilParams.strNullFilter(user.name));
        $("#account_user_view").text(baseUtilParams.strNullFilter(user.account));
        $("#phone_user_view").text(baseUtilParams.strNullFilter(user.phone));
        $("#birthday_user_view").text(baseUtilParams.simpDataForYYYMMDD(user.birthday));
        $("#email_user_view").text(baseUtilParams.strNullFilter(user.email));
        $("#sex_user_view").text(sex[user.sex]);
        $("#create_time_user_view").text(baseUtilParams.simpDataFormat(user.create_time));
        $("#update_time_user_view").text(baseUtilParams.simpDataFormat(user.update_time));
    })
}
/**
 * @title:<h3> 分页查询登录日志 <h3>
 * @author: loy
 * @date: 2018/10/28 19:50
 * @params
 * @return
 **/
function findPageMyLoginLog(cpage) {
    requestUtilParams.findPageData(userViewParams.action.findPageMyLoginLog, cpage, "#table_loginLog","#printPage", findPageMyLoginLog).done(function (result) {
        var list = result.data.list;
        var type = ["pc", "android", "iso"];
        var state = ["登录失败", "登录成功","帐号不存在","密码错误","帐号未激活","帐号被锁定"];
        for (var i = 0; i < list.length; i++) {
            var $tr = $("<tr></tr>");
            $tr.append("<td>" + baseUtilParams.simpDataFormat(list[i].login_date) + "</td>");
            $tr.append("<td>" + list[i].user_account + "</td>");
            $tr.append("<td>" + list[i].request_ip + "</td>");
            $tr.append("<td>" + state[list[i].state] + "</td>");
            $tr.append("<td>" + type[list[i].type] + "</td>");
            $tr.append("<td>" + baseUtilParams.strNullFilter(list[i].model_number) + "</td>");
            $tr.append("<td>" + baseUtilParams.strNullFilter(list[i].imei) + "</td>");
            $("#table_loginLog tbody").append($tr);
        }
    });
}